# Need to specify these items
# 云主机环境
oneAPI_PATH = C:/zongyi/Intel/oneAPI/compiler/2023.2.0/windows
oneMKL_HOME = C:/zongyi/Intel/oneAPI/mkl/2023.2.0
VS_LIBS_HOME = $(VS2019INSTALLDIR)/VC/Tools/MSVC/14.29.30133/lib/x64

oneAPI_LIBS_HOME = $(oneAPI_PATH)/compiler/lib/intel64_win
LINK_LIBS = $(oneAPI_LIBS_HOME)/ifconsol.lib $(oneAPI_LIBS_HOME)/libifcoremt.lib $(oneAPI_LIBS_HOME)/libifport.lib  $(oneAPI_LIBS_HOME)/libircmt.lib \
	$(oneAPI_LIBS_HOME)/ifmodintr.lib $(oneAPI_LIBS_HOME)/svml_dispmt.lib $(oneAPI_LIBS_HOME)/libirc.lib $(oneAPI_LIBS_HOME)/libmmt.lib\
	$(oneAPI_LIBS_HOME)/libiomp5md.lib "$(VS_LIBS_HOME)/libcmt.lib" "$(VS_LIBS_HOME)/oldnames.lib" "$(VS_LIBS_HOME)/libvcruntime.lib" \
	"C:\Program Files (x86)/Windows Kits\10\Lib\10.0.19041.0\um\x64\kernel32.lib" \
	"C:\Program Files (x86)/Windows Kits\10\Lib\10.0.19041.0\ucrt\x64\libucrt.lib" \
	"C:\Program Files (x86)/Windows Kits\10\Lib\10.0.19041.0\um\x64\Uuid.lib" \
	"C:\Program Files (x86)/Windows Kits\10\Lib\10.0.19041.0\um\x64\ImageHlp.lib" 

# 本机环境
# oneAPI_PATH = D:/Intel/oneAPI/compiler/2023.1.0/windows
# oneMKL_HOME = D:/Intel/oneAPI/mkl/2023.1.0
# VS_LIBS_HOME = $(VS2019INSTALLDIR)/VC/Tools/MSVC/14.29.30133/lib/x64

# oneAPI_LIBS_HOME = $(oneAPI_PATH)/compiler/lib/intel64_win
# LINK_LIBS = $(oneAPI_LIBS_HOME)/ifconsol.lib $(oneAPI_LIBS_HOME)/libifcoremt.lib $(oneAPI_LIBS_HOME)/libifport.lib  $(oneAPI_LIBS_HOME)/libircmt.lib \
# 	$(oneAPI_LIBS_HOME)/ifmodintr.lib $(oneAPI_LIBS_HOME)/svml_dispmt.lib $(oneAPI_LIBS_HOME)/libirc.lib $(oneAPI_LIBS_HOME)/libmmt.lib\
# 	$(oneAPI_LIBS_HOME)/libiomp5md.lib "$(VS_LIBS_HOME)/libcmt.lib" "$(VS_LIBS_HOME)/oldnames.lib" "$(VS_LIBS_HOME)/libvcruntime.lib" \
# 	"D:\Windows Kits\10\Lib\10.0.19041.0\um\x64\kernel32.lib" \
# 	"D:\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64\libucrt.lib" \
# 	"D:\Windows Kits\10\Lib\10.0.19041.0\um\x64\Uuid.lib" \
# 	"D:\Windows Kits\10\Lib\10.0.19041.0\um\x64\ImageHlp.lib" 

FC = $(oneAPI_PATH)/bin/ifx.exe
FFLAGS = -O3 -openmp /fp:fast #/march=native /mavx2 /ffast-math

all : test.exe

test.exe: readData.o writeData.o checkData.o basicMathSubroutines.o computeResidual.o main.o #libsolver.lib
	$(FC) $^ $(LAPACK) $(LINK_LIBS) -o $@ 

readData.o: readData.f90
	$(FC) -c $^ $(FFLAGS) -o $@
writeData.o: writeData.f90
	$(FC) -c $^ $(FFLAGS) -o $@
checkData.o: checkData.f90
	$(FC) -c $^ $(FFLAGS) -o $@
basicMathSubroutines.o : basicMathSubroutines.f90
	$(FC) -c $^ $(FFLAGS) -o $@
computeResidual.o : computeResidual.f90
	$(FC) -c $^ $(FFLAGS) -I$(oneMKL_HOME)/include/intel64/lp64 -o $@
checkInputData.o: checkInputData.f90
	$(FC) -c $^ $(FFLAGS) -o $@
main.o: main.f90
	$(FC) -c $^ $(FFLAGS) -I$(oneMKL_HOME)/include/intel64/lp64 -o $@

clean:
	del *.o *.mod *.exe *.lib *.exp *.dll
